local addonName = "Altoholic"
local addon = _G[addonName]

local WHITE		= "|cFFFFFFFF"
local GREEN		= "|cFF00FF00"
local YELLOW	= "|cFFFFFF00"

local RECIPE_GREY		= "|cFF808080"
local RECIPE_GREEN	= "|cFF40C040"
local RECIPE_ORANGE	= "|cFFFF8040"

local ICON_NOTREADY = "\124TInterface\\RaidFrame\\ReadyCheck-NotReady:14\124t"
local ICON_READY = "\124TInterface\\RaidFrame\\ReadyCheck-Ready:14\124t"
local ICON_QUESTIONMARK = "Interface\\RaidFrame\\ReadyCheck-Waiting"


-- based on Ackis Recipe List 2.4.1

-- ** Primary Skills **

local alchemy = {
	{	-- "Classic"
		-- MoP : 3172, 11453 removed
		2329, 2330, 2331, 2332, 2333, 2334, 2335, 2337, 3170, 3171, 
		3173, 3174, 3175, 3176, 3177, 3188, 3230, 3447, 3448, 
		3449, 3450, 3451, 3452, 3453, 3454, 4508, 4942, 6617, 6618, 
		6624, 7179, 7181, 7183, 7255, 7256, 7257, 7258, 7259, 7836, 
		7837, 7841, 7845, 8240, 11448, 11449, 11450, 11451, 11452, 
		11456, 11457, 11458, 11459, 11460, 11461, 11464, 11465, 11466, 11467, 
		11468, 11472, 11473, 11476, 11477, 11478, 11479, 11480, 12609, 15833, 
		17187, 17551, 17552, 17553, 17554, 17555, 17556, 17557, 17559, 17560, 
		17561, 17562, 17563, 17564, 17565, 17566, 17570, 17571, 17572, 17573, 
		17574, 17575, 17576, 17577, 17578, 17580, 17634, 21923, 22732, 22808, 
		24266, 24365, 24366, 24367, 24368, 25146, 26277, 
	},
	{	-- "The Burning Crusade"
		-- MoP : 17638, 42736 removed
		17632, 17635, 17636, 17637, 28543, 28544, 28545, 28546, 28549, 
		28550, 28551, 28552, 28553, 28554, 28555, 28556, 28557, 28558, 28562, 
		28563, 28564, 28565, 28566, 28567, 28568, 28569, 28570, 28571, 28572, 
		28573, 28575, 28576, 28577, 28578, 28579, 28580, 28581, 28582, 28583, 
		28584, 28585, 28586, 28587, 28588, 28589, 28590, 28591, 29688, 32765, 
		32766, 33732, 33733, 33738, 33740, 33741, 38070, 38960, 38961, 38962, 
		39636, 39637, 39638, 39639, 41458, 41500, 41501, 41502, 41503, 
		45061, 47046, 47048, 47049, 47050, 
	},
	{	-- "Wrath of the Lich King"
		-- MoP : 62213, 67025 removed
		53771, 53773, 53774, 53775, 53776, 53777, 53779, 53780, 53781, 53782, 
		53783, 53784, 53812, 53836, 53837, 53838, 53839, 53840, 53841, 53842, 
		53847, 53848, 53895, 53898, 53899, 53900, 53901, 53902, 53903, 53904, 
		53905, 53936, 53937, 53938, 53939, 53942, 54213, 54218, 54220, 54221, 
		54222, 56519, 57425, 57427, 58868, 58871, 60350, 60354, 60355, 60356, 
		60357, 60365, 60366, 60367, 60396, 60403, 60405, 60893, 62409, 
		62410, 63732, 66658, 66659, 66660, 66662, 66663, 66664, 
	},
	{	-- "Cataclysm"
		-- MoP : 80724 removed
		78866, 80237, 80243, 80244, 80245, 80246, 80247, 80248, 80250, 80251, 
		80269, 80477, 80478, 80479, 80480, 80481, 80482, 80484, 80486, 80487, 
		80488, 80490, 80491, 80492, 80493, 80494, 80495, 80496, 80497, 80498, 
		80508, 80719, 80720, 80721, 80723, 80725, 80726, 92643, 92688, 
		93328, 93935, 94162, 96252, 96253, 96254, 
	},
	{	-- "Mists of Pandaria"
		114751, 114752, 114753, 114754, 114755, 114756, 114757, 114758, 114759, 114760, 
		114761, 114762, 114763, 114764, 114765, 114766, 114767, 114769, 114770, 114771, 
		114772, 114773, 114774, 114775, 114776, 114777, 114778, 114779, 114780, 114781, 
		114782, 114783, 114784, 114786, 130326, 
	},
}

local blacksmithing = {
	{	-- "Classic"
		-- MoP : 7818, 14379, 14380, 20201 removed
		2660, 2661, 2662, 2663, 2664, 2665, 2666, 2667, 2668, 2670, 
		2672, 2673, 2674, 2675, 2737, 2738, 2739, 2740, 2741, 2742, 
		3115, 3116, 3117, 3292, 3293, 3294, 3295, 3296, 3297, 3319, 
		3320, 3321, 3323, 3324, 3325, 3326, 3328, 3330, 3331, 3333, 
		3334, 3336, 3337, 3491, 3492, 3493, 3494, 3495, 3496, 3497, 
		3498, 3500, 3501, 3502, 3503, 3504, 3505, 3506, 3507, 3508, 
		3511, 3513, 3515, 6517, 6518, 7221, 7222, 7223, 7224, 7408, 
		7817, 8367, 8768, 8880, 9811, 9813, 9814, 9818, 9820, 
		9916, 9918, 9920, 9921, 9926, 9928, 9931, 9933, 9935, 9937, 
		9939, 9945, 9950, 9952, 9954, 9957, 9959, 9961, 9964, 9966, 
		9968, 9970, 9972, 9974, 9979, 9980, 9983, 9985, 9986, 9987, 
		9993, 9995, 9997, 10001, 10003, 10005, 10007, 10009, 10011, 10013,
		10015, 11454, 11643, 12259, 12260, 15292, 15293, 15294, 
		15295, 15296, 15972, 15973, 16639, 16640, 16641, 16642, 16643, 16644, 
		16645, 16646, 16647, 16648, 16649, 16650, 16651, 16652, 16653, 16654, 
		16655, 16656, 16657, 16658, 16659, 16660, 16661, 16662, 16663, 16664, 
		16665, 16667, 16724, 16725, 16726, 16728, 16729, 16730, 16731, 16732, 
		16741, 16742, 16744, 16745, 16746, 16969, 16970, 16971, 16973, 16978, 
		16983, 16984, 16985, 16988, 16990, 16991, 16992, 16993, 16994, 16995, 
		19666, 19667, 19668, 19669, 20872, 20873, 20874, 20876, 20890, 
		20897, 21161, 21913, 22757, 23628, 23629, 23632, 23633, 23636, 23637, 
		23638, 23639, 23650, 23652, 23653, 24136, 24137, 24138, 24139, 24140, 
		24141, 24399, 24912, 24913, 24914, 27585, 27586, 27587, 27588, 27589,
		27590, 27829, 27830, 27832, 28242, 28243, 28244, 28461, 28462, 28463, 
	},
	{	-- "The Burning Crusade"
		-- MoP : 32655, 32656, 32657, 34979, 34981, 34982, 34983 removed
		29545, 29547, 29548, 29549, 29550, 29551, 29552, 29553, 29556, 29557, 
		29558, 29565, 29566, 29568, 29569, 29571, 29603, 29605, 29606, 29608, 
		29610, 29611, 29613, 29614, 29615, 29616, 29617, 29619, 29620, 29621, 
		29622, 29628, 29629, 29630, 29642, 29643, 29645, 29648, 29649, 29654, 
		29656, 29657, 29658, 29662, 29663, 29664, 29668, 29669, 29671, 29672, 
		29692, 29693, 29694, 29695, 29696, 29697, 29698, 29699, 29700, 29728, 
		29729, 32284, 32285, 34529, 34530, 34533, 34534, 34535, 34537, 34538, 
		34540, 34541, 34542, 34543, 34544, 34545, 34546, 34547, 34548, 34607, 
		34608, 36122, 36124, 36125, 36126, 36128, 36129, 36130, 36131, 36133,
		36134, 36135, 36136, 36137, 36256, 36257, 36258, 36259, 36260, 36261, 
		36262, 36263, 36389, 36390, 36391, 36392, 38473, 38475, 38476, 38477, 
		38478, 38479, 40033, 40034, 40035, 40036, 41132, 41133, 41134, 41135,
		42662, 42688, 43549, 43846, 46140, 46141, 46142, 46144, 
	},
	{	-- "Wrath of the Lich King"
		-- MoP : 55202, 55732 removed
		52567, 52568, 52569, 52570, 52571, 52572, 54550, 54551, 54552, 54553, 
		54554, 54555, 54556, 54557, 54917, 54918, 54941, 54944, 54945, 54946, 
		54947, 54948, 54949, 54978, 54979, 54980, 54981, 55013, 55014, 55015, 
		55017, 55055, 55056, 55057, 55058, 55174, 55177, 55179, 55181, 55182, 
		55183, 55184, 55185, 55186, 55187, 55200, 55201, 55203, 55204, 
		55206, 55298, 55300, 55301, 55302, 55303, 55304, 55305, 55306, 55307, 
		55308, 55309, 55310, 55311, 55312, 55369, 55370, 55371, 55372, 55373, 
		55374, 55375, 55376, 55377, 55628, 55641, 55656, 55834, 55835, 
		55839, 56234, 56280, 56357, 56400, 56549, 56550, 56551, 56552, 56553, 
		56554, 56555, 56556, 59405, 59406, 59436, 59438, 59440, 59441, 59442, 
		61008, 61009, 61010, 62202, 63182, 63187, 63188, 63189, 63190, 63191, 
		63192, 67091, 67092, 67093, 67094, 67095, 67096, 67130, 67131, 67132, 
		67133, 67134, 67135, 70562, 70563, 70565, 70566, 70567, 70568, 
	},
	{	-- "Cataclysm"
		-- MoP : 92375 removed
		76178, 76179, 76180, 76181, 76182, 76258, 76259, 76260, 76261, 76262, 
		76263, 76264, 76265, 76266, 76267, 76269, 76270, 76280, 76281, 76283, 
		76285, 76286, 76287, 76288, 76289, 76291, 76293, 76433, 76434, 76435, 
		76436, 76437, 76438, 76439, 76440, 76441, 76442, 76443, 76444, 76445, 
		76446, 76447, 76448, 76449, 76450, 76451, 76452, 76453, 76454, 76455, 
		76456, 76457, 76458, 76459, 76461, 76462, 76463, 76464, 76465, 76466, 
		76467, 76468, 76469, 76470, 76471, 76472, 76474, 94718, 94732, 
		99439, 99440, 99441, 99452, 99453, 99454, 99652, 99653, 99654, 99655, 
		99656, 99657, 99658, 99660, 101924,101925,101928,101929,101931,101932,
	},
	{	-- "Mists of Pandaria"
		113263, 114112, 122568, 122569, 122570, 122571, 122572, 122573, 122574, 122575, 
		122576, 122577, 122578, 122579, 122580, 122581, 122582, 122583, 122584, 122585, 
		122586, 122587, 122588, 122589, 122590, 122591, 122592, 122593, 122594, 122595, 
		122596, 122597, 122598, 122599, 122600, 122601, 122602, 122603, 122604, 122605, 
		122606, 122607, 122608, 122609, 122610, 122611, 122612, 122613, 122614, 122615, 
		122616, 122617, 122618, 122619, 122620, 122621, 122622, 122623, 122624, 122625, 
		122626, 122627, 122628, 122629, 122630, 122631, 122632, 122633, 122635, 122636, 
		122637, 122638, 122639, 122640, 122641, 122642, 122643, 122644, 122645, 122646, 
		122647, 122648, 122649, 122650, 122651, 122652, 122653, 122654, 126850, 126851, 
		126852, 126853, 126854, 126855, 131928, 131929, 
	},
}

local enchanting = {
	{	-- "Classic"
		-- MoP : 7454, 7795, 7861, 13522, 13628, 13657, 13702, 13794, 13933, 20014, 20051, 25081, 25082 removed
		7418, 7420, 7421, 7426, 7428, 7443, 7457, 7745, 7748, 
		7766, 7771, 7776, 7779, 7782, 7786, 7788, 7793, 7857, 
		7859, 7863, 7867, 13378, 13380, 13419, 13421, 13464, 13485, 
		13501, 13503, 13529, 13536, 13538, 13607, 13612, 13617, 13620, 
		13622, 13626, 13631, 13635, 13637, 13640, 13642, 13644, 13646, 
		13648, 13653, 13655, 13659, 13661, 13663, 13687, 13689, 13693, 
		13695, 13698, 13700, 13746, 13815, 13817, 13822, 13836, 
		13841, 13846, 13858, 13868, 13882, 13887, 13890, 13898, 13905, 13915, 
		13917, 13931, 13935, 13937, 13939, 13941, 13943, 13945, 13947, 
		13948, 14293, 14807, 14809, 14810, 15596, 17180, 17181, 20008, 20009, 
		20010, 20011, 20012, 20013, 20015, 20016, 20017, 20020, 20023, 
		20024, 20025, 20026, 20028, 20029, 20030, 20031, 20032, 20033, 20034, 
		20035, 20036, 21931, 22749, 22750, 23799, 23800, 23801, 23802, 
		23803, 23804, 25072, 25073, 25074, 25078, 25079, 25124, 
		25125, 25126, 25127, 25128, 25129, 25130, 27837, 
	},
	{	-- "The Burning Crusade"
		-- MoP : 27926, 27947, 27962, 32664, 32665, 32667, 34005, 34006 removed
		25080, 25083, 25084, 25086, 27899, 27905, 27906, 27911, 27913, 27914, 
		27917, 27920, 27924, 27927, 27944, 27945, 27946, 27948, 
		27950, 27951, 27954, 27957, 27960, 27961, 27967, 27968, 27971, 
		27972, 27975, 27977, 27981, 27982, 27984, 28003, 28004, 28016, 28019, 
		28022, 28027, 28028, 33990, 33991, 33992, 33993, 
		33994, 33995, 33996, 33997, 33999, 34001, 34002, 34003, 34004,  
		34007, 34008, 34009, 34010, 42613, 42615, 42620, 42974, 44383, 
		45765, 46578, 47051, 
	},
	{	-- "Wrath of the Lich King"
		-- MoP : 44483, 44494, 44556, 44590, 44596, 60619 removed
		27958, 44484, 44488, 44489, 44492, 44500, 44506, 44508, 
		44509, 44510, 44513, 44524, 44528, 44529, 44555, 44575, 44576, 
		44582, 44584, 44588, 44589, 44591, 44592, 44593, 44595,  
		44598, 44616, 44621, 44623, 44625, 44629, 44630, 44631, 44633, 44635, 
		44636, 44645, 46594, 47672, 47766, 47898, 47899, 47900, 47901, 59619, 
		59621, 59625, 59636, 60606, 60609, 60616, 60621, 60623, 60653, 
		60663, 60668, 60691, 60692, 60707, 60714, 60763, 60767, 62256, 62948, 
		62959, 63746, 64441, 64579, 69412, 71692, 
	},
	{	-- "Cataclysm"
		-- MoP : 92370 removed
		74132, 74189, 74191, 74192, 74193, 74195, 74197, 74198, 74199, 74200, 
		74201, 74202, 74207, 74211, 74212, 74213, 74214, 74215, 74216, 74217, 
		74218, 74220, 74223, 74225, 74226, 74229, 74230, 74231, 74232, 74234, 
		74235, 74236, 74237, 74238, 74239, 74240, 74242, 74244, 74246, 74247, 
		74248, 74250, 74251, 74252, 74253, 74254, 74255, 74256, 93841, 
		93843, 95471, 96261, 96262, 96264, 104698
	},
	{	-- "Mists of Pandaria"
		103461, 103462, 103463, 103465, 104338, 104385, 104389, 104390, 104391, 104392, 
		104393, 104395, 104397, 104398, 104401, 104403, 104404, 104407, 104408, 104409, 
		104414, 104416, 104417, 104419, 104420, 104425, 104427, 104430, 104434, 104440, 
		104442, 104445, 116497, 116498, 116499, 118237, 118238, 118239, 130758, 
	},
}

local engineering = {
	{	-- "Classic"
		3918, 3919, 3922, 3923, 3925, 3928, 3929, 3931, 3932, 3933, 
		3934, 3936, 3937, 3938, 3939, 3940, 3941, 3942, 3944, 3945, 
		3946, 3949, 3950, 3952, 3953, 3954, 3955, 3956, 3957, 3958, 
		3959, 3960, 3961, 3962, 3963, 3965, 3966, 3967, 3968, 3969, 
		3971, 3972, 3973, 3977, 3978, 3979, 6458, 7430, 8243, 8334, 
		8339, 8895, 9269, 9271, 9273, 12584, 12585, 12586, 12587, 12589, 
		12590, 12591, 12594, 12595, 12597, 12599, 12603, 12607, 12614, 12615, 
		12616, 12617, 12618, 12619, 12620, 12622, 12624, 12715, 12716, 12717, 
		12718, 12754, 12755, 12758, 12759, 12760, 12895, 12897, 12899, 12902, 
		12903, 12905, 12906, 12907, 12908, 13240, 15255, 15628, 15633, 19567, 
		19788, 19790, 19791, 19792, 19793, 19794, 19795, 19796, 19799, 19814, 
		19815, 19819, 19825, 19830, 19831, 19833, 21940, 22704, 22793, 22795, 
		22797, 23066, 23067, 23068, 23069, 23070, 23071, 23077, 23078, 23079, 
		23080, 23081, 23082, 23096, 23129, 23486, 23489, 23507, 24356, 24357, 
		26011, 26416, 26417, 26418, 26420, 26421, 26422, 26423, 26424, 26425, 
		26426, 26427, 26428, 26442, 26443, 28327, 
	},
	{	-- "The Burning Crusade"
		30303, 30304, 30305, 30306, 30307, 30308, 30309, 30310, 30311, 30312, 
		30313, 30314, 30315, 30316, 30317, 30318, 30325, 30329, 30332, 30334, 
		30337, 30341, 30344, 30348, 30547, 30548, 30551, 30552, 30556, 30558, 
		30560, 30563, 30565, 30566, 30568, 30569, 30570, 30574, 30575, 32814, 
		36954, 36955, 39895, 39971, 39973, 40274, 41307, 41311, 41312, 41314, 
		41315, 41316, 41317, 41318, 41319, 41320, 41321, 43676, 44155, 44157, 
		44391, 46106, 46107, 46108, 46109, 46110, 46111, 46112, 46113, 46114, 
		46115, 46116, 46697, 53281, 56349, 56459, 56460, 
	},
	{	-- "Wrath of the Lich King"
		30349, 54353, 54736, 54793, 54998, 54999, 55002, 55016, 55252, 56461, 
		56462, 56463, 56464, 56465, 56466, 56467, 56468, 56469, 56470, 56471, 
		56472, 56473, 56476, 56477, 56478, 56479, 56480, 56481, 56483, 56484, 
		56486, 56487, 56514, 56574, 60866, 60867, 60874, 61471, 61481, 61482, 
		61483, 62271, 63750, 63770, 67326, 67839, 67920, 68067, 
	},
	{	-- "Cataclysm"
		-- MoP : 82201 removed
		81714, 81715, 81716, 81720, 81722, 81724, 81725, 82175, 82177, 82180, 
		82200, 84403, 84406, 84408, 84409, 84410, 84411, 84412, 84413, 
		84415, 84416, 84417, 84418, 84420, 84421, 84424, 84425, 84427, 84428, 
		84429, 84430, 84431, 84432, 94748, 95703, 95705, 95707, 100587,100687
	},
	{	-- "Mists of Pandaria"
		108789, 109077, 109099, 126392, 126731, 127113, 127114, 127115, 127116, 127117, 
		127118, 127119, 127120, 127121, 127122, 127123, 127124, 127127, 127128, 127129, 
		127130, 127131, 127132, 127134, 127135, 127136, 127137, 127138, 127139, 128260, 
		128261, 128262, 131211, 131212, 131213, 131214, 131215, 131216, 131217, 131218, 
		131256, 131258, 131353, 131563, 
	},
}

local inscription = {
	{	-- "Classic"
	},
	{	-- "The Burning Crusade"
	},
	{	-- "Wrath of the Lich King"
		-- MoP : 57272, 56977 removed
		45382, 48114, 48116, 48121, 48247, 48248, 50598, 50599, 50600, 50601, 
		50602, 50603, 50604, 50605, 50606, 50607, 50608, 50609, 50610, 50611, 
		50612, 50614, 50616, 50617, 50618, 50619, 50620, 52738, 52739, 52843, 
		53462, 56943, 56944, 56945, 56946, 56947, 56948, 56949, 56950, 56951, 
		56952, 56953, 56954, 56955, 56956, 56957, 56958, 56959, 56960, 56961, 
		56963, 56965, 56971, 56972, 56973, 56974, 56975, 56976, 56978, 
		56979, 56980, 56981, 56983, 56984, 56986, 56987, 56988, 56989, 56990, 
		56991, 56994, 56995, 56996, 56997, 56998, 56999, 57000, 57001, 57002, 
		57003, 57004, 57005, 57006, 57007, 57008, 57009, 57010, 57011, 57012, 
		57014, 57019, 57020, 57021, 57022, 57023, 57024, 57025, 57026, 57027, 
		57028, 57029, 57030, 57031, 57032, 57033, 57034, 57035, 57036, 57112, 
		57113, 57114, 57115, 57116, 57117, 57119, 57120, 57121, 57122, 57123, 
		57124, 57125, 57126, 57127, 57128, 57129, 57130, 57131, 57132, 57133, 
		57152, 57153, 57154, 57155, 57156, 57157, 57158, 57159, 57160, 57161, 
		57162, 57163, 57164, 57165, 57167, 57168, 57170, 57172, 57181, 57183, 
		57184, 57185, 57186, 57187, 57188, 57189, 57190, 57191, 57192, 57193, 
		57194, 57195, 57196, 57197, 57198, 57199, 57200, 57201, 57202, 57207, 
		57208, 57209, 57210, 57211, 57213, 57214, 57215, 57216, 57217, 57219, 
		57220, 57221, 57222, 57223, 57224, 57225, 57226, 57227, 57228, 57229, 
		57230, 57232, 57233, 57234, 57235, 57236, 57237, 57238, 57239, 57240, 
		57241, 57242, 57243, 57244, 57245, 57246, 57247, 57248, 57249, 57250, 
		57251, 57252, 57253, 57257, 57258, 57259, 57260, 57261, 57262, 57263, 
		57264, 57265, 57266, 57267, 57268, 57269, 57270, 57271, 57274, 
		57275, 57276, 57277, 57703, 57704, 57706, 57707, 57708, 57709, 57710, 
		57711, 57712, 57713, 57714, 57715, 57716, 58286, 58287, 58288, 58289, 
		58296, 58297, 58298, 58299, 58301, 58302, 58303, 58306, 58307, 58308, 
		58310, 58311, 58312, 58313, 58314, 58315, 58316, 58317, 58318, 58319, 
		58320, 58321, 58322, 58323, 58324, 58325, 58326, 58327, 58328, 58329, 
		58330, 58331, 58332, 58333, 58336, 58337, 58338, 58339, 58340, 58341, 
		58342, 58343, 58344, 58345, 58346, 58347, 58472, 58473, 58476, 58478, 
		58480, 58481, 58482, 58483, 58484, 58485, 58486, 58487, 58488, 58489, 
		58490, 58491, 58565, 59315, 59326, 59338, 59339, 59340, 59387, 59475, 
		59478, 59480, 59484, 59486, 59487, 59489, 59490, 59491, 59493, 59494, 
		59495, 59496, 59497, 59498, 59502, 59503, 59504, 59559, 59560, 59561, 
		60336, 60337, 61117, 61118, 61119, 61120, 61177, 61288, 61677, 62162, 
		64051, 64053, 64246, 64247, 64248, 64249, 64250, 64251, 64252, 64253, 
		64254, 64255, 64256, 64257, 64258, 64259, 64260, 64261, 64262, 64266, 
		64268, 64270, 64271, 64273, 64274, 64275, 64276, 64277, 64278, 64279, 
		64280, 64281, 64282, 64283, 64284, 64285, 64286, 64287, 64288, 64289, 
		64291, 64294, 64295, 64296, 64297, 64298, 64300, 64302, 64303, 64304, 
		64305, 64307, 64308, 64309, 64310, 64311, 64312, 64313, 64314, 64315, 
		64316, 64317, 64318, 67600, 68166, 69385, 71101, 71102, 94000, 
	},
	{	-- "Cataclysm"
		-- MoP : 86647, 86650, 89367, 99547, 99548, 99549 removed
		85785, 86004, 86005, 86375, 86401, 86402, 86403, 86609, 86615, 86616, 
		86640, 86641, 86642, 86643, 86644, 86645, 86646, 86648, 86649, 
		86652, 86653, 86654, 89244, 89368, 89369, 89370, 89371, 
		89372, 89373, 89815, 92026, 92027, 92579, 94401, 94402, 94403, 94404, 
		94405, 94406, 94711, 95215, 95710, 95825, 96284, 98398,  
		101057,107907,
	},
	{	-- "Mists of Pandaria"
		57037, 58309, 111645, 111646, 111830, 111908, 111909, 111910, 111917, 111918, 
		111919, 111920, 111921, 112045, 112264, 112265, 112266, 112429, 112430, 112437, 
		112440, 112442, 112444, 112450, 112451, 112452, 112454, 112457, 112458, 112460, 
		112461, 112462, 112463, 112464, 112465, 112466, 112468, 112469, 112883, 112996, 
		119481, 122015, 122030, 123781, 124442, 124443, 124444, 124445, 124446, 124447, 
		124448, 124449, 124450, 124451, 124452, 124453, 124454, 124455, 124456, 124457, 
		124459, 124460, 124461, 124463, 124466, 126153, 126687, 126696, 126701, 126704, 
		126800, 126801, 126988, 126989, 126994, 126995, 126996, 126997, 127007, 127009, 
		127016, 127017, 127018, 127019, 127020, 127021, 127023, 127024, 127378, 127391, 
		127625, 128922, 130407, 131152, 132167, 
	},
}

local jewelcrafting = {
	{	-- "Classic"
	},
	{	-- "The Burning Crusade"
		25255, 25278, 25280, 25283, 25284, 25287, 25305, 25317, 25318, 25320, 
		25321, 25323, 25339, 25490, 25493, 25498, 25610, 25612, 25613, 25615, 
		25617, 25618, 25619, 25620, 25621, 25622, 26872, 26873, 26874, 26875, 
		26876, 26878, 26880, 26881, 26882, 26883, 26885, 26887, 26896, 26897, 
		26900, 26902, 26903, 26906, 26907, 26908, 26909, 26910, 26911, 26912, 
		26914, 26915, 26916, 26925, 26926, 26927, 26928, 28903, 28905, 28910, 
		28912, 28914, 28915, 28916, 28917, 28918, 28925, 28927, 28933, 28936, 
		28944, 28947, 28948, 28950, 28953, 28955, 31048, 31049, 31050, 31051, 
		31052, 31053, 31054, 31055, 31056, 31057, 31058, 31060, 31061, 31062, 
		31063, 31064, 31065, 31066, 31067, 31068, 31070, 31071, 31072, 31076, 
		31077, 31078, 31079, 31080, 31081, 31082, 31083, 31084, 31085, 31088, 
		31090, 31091, 31092, 31095, 31097, 31098, 31101, 31102, 31103, 31104, 
		31106, 31107, 31108, 31109, 31111, 31112, 31113, 31149, 32178, 32179, 
		32259, 32801, 32807, 32808, 32809, 32866, 32867, 32868, 32869, 32870, 
		32871, 32872, 32873, 32874, 34590, 34955, 34959, 34960, 34961, 36523, 
		36524, 36525, 36526, 37818, 37855, 38068, 38175, 38503, 38504, 39466, 
		39467, 39470, 39471, 39705, 39706, 39711, 39713, 39714, 39715, 39716, 
		39718, 39720, 39721, 39724, 39727, 39728, 39731, 39733, 39734, 39736, 
		39737, 39738, 39739, 39740, 39741, 39742, 39961, 39963, 40514, 41414, 
		41415, 41418, 41420, 41429, 42558, 42588, 42589, 42590, 42591, 42592, 
		42593, 43493, 44794, 46122, 46123, 46124, 46125, 46126, 46127, 46403, 
		46405, 46597, 46601, 46775, 46776, 46777, 46778, 46779, 46803, 47053, 
		47054, 47055, 47056, 47280, 
	},
	{	-- "Wrath of the Lich King"
		53830, 53831, 53832, 53843, 53844, 53845, 53852, 53854, 53856, 53857, 
		53859, 53860, 53861, 53865, 53869, 53870, 53871, 53872, 53873, 53874, 
		53875, 53876, 53877, 53879, 53880, 53882, 53883, 53884, 53885, 53891, 
		53892, 53893, 53894, 53917, 53918, 53919, 53920, 53921, 53922, 53923, 
		53924, 53925, 53932, 53933, 53934, 53941, 53943, 53945, 53946, 53948, 
		53949, 53951, 53952, 53954, 53955, 53957, 53958, 53960, 53961, 53962, 
		53963, 53965, 53966, 53968, 53972, 53974, 53975, 53976, 53977, 53978, 
		53980, 53981, 53984, 53985, 53986, 53987, 53988, 53991, 53993, 53994, 
		53996, 53997, 53998, 54000, 54001, 54003, 54005, 54009, 54011, 54012, 
		54014, 54017, 54019, 54023, 55384, 55386, 55387, 55388, 55389, 55390, 
		55392, 55393, 55394, 55395, 55396, 55397, 55398, 55399, 55400, 55401, 
		55402, 55403, 55404, 55405, 55407, 56049, 56052, 56053, 56055, 56056, 
		56079, 56081, 56083, 56084, 56085, 56086, 56087, 56088, 56193, 56194, 
		56195, 56196, 56197, 56199, 56201, 56202, 56203, 56205, 56206, 56208, 
		56496, 56497, 56498, 56499, 56500, 56501, 56530, 56531, 58141, 58142, 
		58143, 58144, 58145, 58146, 58147, 58148, 58149, 58150, 58492, 58507, 
		58954, 59759, 62242, 62941, 63743, 64725, 64726, 64727, 64728, 66338, 
		66428, 66429, 66431, 66432, 66434, 66435, 66439, 66441, 66442, 66443, 
		66445, 66446, 66447, 66448, 66450, 66452, 66453, 66497, 66498, 66499, 
		66501, 66502, 66505, 66506, 66554, 66556, 66557, 66560, 66561, 66562, 
		66567, 66568, 66569, 66570, 66571, 66572, 66573, 66574, 66576, 66579, 
		66581, 66582, 66583, 66584, 66585, 66586, 68253, 
	},
	{	-- "Cataclysm"
		73222, 73223, 73224, 73225, 73226, 73227, 73228, 73229, 73230, 73231, 
		73232, 73234, 73239, 73240, 73241, 73242, 73243, 73244, 73245, 73246, 
		73247, 73248, 73249, 73250, 73258, 73260, 73262, 73263, 73264, 73265, 
		73266, 73267, 73268, 73269, 73270, 73271, 73272, 73273, 73274, 73275, 
		73276, 73277, 73278, 73279, 73280, 73281, 73335, 73336, 73337, 73338, 
		73339, 73340, 73341, 73343, 73344, 73345, 73346, 73347, 73348, 73349, 
		73350, 73351, 73352, 73353, 73354, 73355, 73356, 73357, 73358, 73359, 
		73360, 73361, 73362, 73364, 73365, 73366, 73367, 73368, 73369, 73370, 
		73371, 73372, 73373, 73374, 73375, 73376, 73377, 73378, 73379, 73380, 
		73381, 73382, 73383, 73384, 73396, 73397, 73398, 73399, 73400, 73401, 
		73402, 73403, 73404, 73405, 73406, 73407, 73408, 73409, 73464, 73465, 
		73466, 73467, 73468, 73469, 73470, 73471, 73472, 73473, 73474, 73475, 
		73476, 73478, 73494, 73495, 73496, 73497, 73498, 73502, 73503, 73504, 
		73505, 73506, 73520, 73521, 73620, 73621, 73622, 73625, 73626, 73627, 
		95754, 95755, 95756, 96226, 96255, 96256, 96257, 98921, 99539, 99540, 
		99541, 99542, 99543, 99544, 101735, 101740, 101741, 101742, 101743, 101744, 
		101745, 101746, 101747, 101748, 101749, 101750, 101751, 101752, 101753, 101754, 
		101755, 101756, 101757, 101758, 101759, 101760, 101761, 101762, 101763, 101764, 
		101765, 101766, 101767, 101768, 101769, 101770, 101771, 101772, 101773, 101774, 
		101775, 101776, 101777, 101778, 101779, 101780, 101781, 101782, 101783, 101784, 
		101785, 101786, 101787, 101788, 101789, 101790, 101791, 101792, 101793, 101794, 
		101795, 101796, 101797, 101798, 101799, 101800, 101801, 101802, 101803, 101804, 
	},
	{	-- "Mists of Pandaria"
		106947, 106948, 106949, 106950, 106953, 106954, 106955, 106956, 106957, 106958, 
		106960, 106961, 106962, 107598, 107599, 107600, 107601, 107602, 107604, 107605, 
		107606, 107607, 107608, 107609, 107610, 107611, 107612, 107613, 107614, 107615, 
		107616, 107617, 107619, 107620, 107621, 107622, 107623, 107624, 107625, 107626, 
		107627, 107628, 107630, 107631, 107632, 107633, 107634, 107635, 107636, 107637, 
		107638, 107639, 107640, 107641, 107642, 107643, 107644, 107645, 107646, 107647, 
		107648, 107649, 107650, 107651, 107652, 107653, 107654, 107655, 107656, 107657, 
		107658, 107659, 107660, 107661, 107662, 107663, 107665, 107666, 107667, 107693, 
		107694, 107695, 107696, 107697, 107698, 107699, 107700, 107701, 107702, 107703, 
		107704, 107705, 107706, 107707, 107708, 107709, 107710, 107711, 107712, 107713, 
		107714, 107715, 107716, 107717, 107718, 107719, 107720, 107721, 107722, 107723, 
		107724, 107725, 107726, 107727, 107728, 107729, 107730, 107731, 107732, 107733, 
		107734, 107735, 107736, 107737, 107738, 107739, 107740, 107742, 107743, 107744, 
		107745, 107746, 107753, 107754, 107756, 107757, 107758, 107759, 107760, 107762, 
		107763, 107764, 107765, 107766, 107767, 107768, 120045, 121841, 121842, 121843, 
		121844, 122661, 122662, 122663, 122664, 122665, 122666, 122667, 122668, 122669, 
		122670, 122671, 122672, 122673, 122674, 122675, 122676, 122677, 122678, 122679, 
		122680, 122681, 122682, 122683, 122684, 122685, 130655, 130656, 130657, 130658, 
		131593, 131686, 131688, 131690, 131691, 131695, 131759, 131897, 131898, 
	},
}

local leatherworking = {
	{	-- "Classic"
		2149, 2152, 2153, 2158, 2159, 2160, 2161, 2162, 2163, 2164, 
		2165, 2166, 2167, 2168, 2169, 2881, 3753, 3756, 3759, 3760, 
		3761, 3762, 3763, 3764, 3765, 3766, 3767, 3768, 3769, 3770, 
		3771, 3772, 3773, 3774, 3775, 3776, 3777, 3778, 3779, 3780, 
		3816, 3817, 3818, 4097, 5244, 6661, 6702, 6703, 6704, 6705, 
		7126, 7133, 7135, 7147, 7149, 7151, 7153, 7156, 7953, 7954, 
		7955, 8322, 9058, 9059, 9064, 9065, 9068, 9070, 9072, 9074, 
		9145, 9146, 9147, 9148, 9149, 9195, 9196, 9197, 9198, 9201, 
		9202, 9206, 9207, 9208, 10482, 10487, 10490, 10499, 10507, 10509, 
		10511, 10516, 10518, 10520, 10525, 10529, 10531, 10533, 10542, 10544, 
		10546, 10548, 10552, 10554, 10556, 10558, 10560, 10562, 10564, 10566, 
		10568, 10570, 10572, 10574, 10619, 10621, 10630, 10632, 10647, 10650, 
		19047, 19048, 19049, 19050, 19051, 19052, 19053, 19054, 19055, 19058, 
		19059, 19060, 19061, 19062, 19063, 19064, 19065, 19066, 19067, 19068, 
		19070, 19071, 19072, 19073, 19074, 19075, 19076, 19077, 19078, 19079, 
		19080, 19081, 19082, 19083, 19084, 19085, 19086, 19087, 19088, 19089, 
		19090, 19091, 19092, 19093, 19094, 19095, 19097, 19098, 19100, 19101, 
		19102, 19103, 19104, 19107, 20648, 20649, 20650, 20853, 20854, 20855, 
		21943, 22331, 22711, 22727, 22815, 22921, 22922, 22923, 22926, 22927, 
		22928, 23190, 23399, 23703, 23704, 23705, 23706, 23707, 23708, 23709, 
		23710, 24121, 24122, 24123, 24124, 24125, 24654, 24655, 24703, 24846, 
		24847, 24848, 24849, 24850, 24851, 24940, 26279, 28219, 28220, 28221, 
		28222, 28223, 28224, 28472, 28473, 28474, 
	},
	{	-- "The Burning Crusade"
		32454, 32455, 32456, 32457, 32458, 32461, 32462, 32463, 32464, 32465, 
		32466, 32467, 32468, 32469, 32470, 32471, 32472, 32473, 32478, 32479, 
		32480, 32481, 32482, 32485, 32487, 32488, 32489, 32490, 32493, 32494, 
		32495, 32496, 32497, 32498, 32499, 32500, 32501, 32502, 32503, 35520, 
		35521, 35522, 35523, 35524, 35525, 35526, 35527, 35528, 35529, 35530, 
		35531, 35532, 35533, 35534, 35535, 35536, 35537, 35538, 35539, 35540, 
		35543, 35544, 35549, 35554, 35555, 35557, 35558, 35559, 35560, 35561, 
		35562, 35563, 35564, 35567, 35568, 35572, 35573, 35574, 35575, 35576, 
		35577, 35580, 35582, 35584, 35585, 35587, 35588, 35589, 35590, 35591, 
		36074, 36075, 36076, 36077, 36078, 36079, 36349, 36351, 36352, 36353, 
		36355, 36357, 36358, 36359, 39997, 40001, 40002, 40003, 40004, 40005, 
		40006, 41156, 41157, 41158, 41160, 41161, 41162, 41163, 41164, 42546, 
		42731, 44359, 44770, 44953, 44970, 45100, 45117, 46132, 46133, 46134, 
		46135, 46136, 46137, 46138, 46139, 
	},
	{	-- "Wrath of the Lich King"
		-- MoP : 57692, 57694, 57696, 57699, 57701, 60583, 60584 removed
		4096, 50936, 50938, 50939, 50940, 50941, 50942, 50943, 50944, 50945, 
		50946, 50947, 50948, 50949, 50950, 50951, 50952, 50953, 50954, 50955, 
		50956, 50957, 50958, 50959, 50960, 50961, 50962, 50963, 50964, 50965, 
		50966, 50967, 50970, 50971, 51568, 51569, 51570, 51571, 51572, 52733, 
		55199, 57683, 57690, 57691, 
		60599, 60600, 60601, 60604, 60605, 60607, 60608, 60611, 60613, 
		60620, 60622, 60624, 60627, 60629, 60630, 60631, 60637, 60640, 60643, 
		60649, 60651, 60652, 60655, 60658, 60660, 60665, 60666, 60669, 60671, 
		60697, 60702, 60703, 60704, 60705, 60706, 60711, 60712, 60715, 60716, 
		60718, 60720, 60721, 60723, 60725, 60727, 60728, 60729, 60730, 60731, 
		60732, 60734, 60735, 60737, 60743, 60746, 60747, 60748, 60749, 60750, 
		60751, 60752, 60754, 60755, 60756, 60757, 60758, 60759, 60760, 60761, 
		60996, 60997, 60998, 60999, 61000, 61002, 62176, 62177, 62448, 63194, 
		63195, 63196, 63197, 63198, 63199, 63200, 63201, 64661, 67080, 67081, 
		67082, 67083, 67084, 67085, 67086, 67087, 67136, 67137, 67138, 67139, 
		67140, 67141, 67142, 67143, 69386, 69388, 70554, 70555, 70556, 70557, 
		70558, 70559, 70560, 70561, 
	},
	{	-- "Cataclysm"
		-- MoP : 85067, 85068, 101600 removed
		78379, 78380, 78388, 78396, 78398, 78399, 78405, 78406, 78407, 78410, 
		78411, 78415, 78416, 78419, 78420, 78423, 78424, 78427, 78428, 78432, 
		78433, 78436, 78437, 78438, 78439, 78444, 78445, 78446, 78447, 78448, 
		78449, 78450, 78451, 78452, 78453, 78454, 78455, 78456, 78457, 78458, 
		78459, 78460, 78461, 78462, 78463, 78464, 78467, 78468, 78469, 78470, 
		78471, 78473, 78474, 78475, 78476, 78477, 78478, 78479, 78480, 78481, 
		78482, 78483, 78484, 78485, 78486, 78487, 78488, 78489, 78490, 84950, 
		85007, 85008, 85009, 85010, 99443, 99445, 99446, 99447, 
		99455, 99456, 99457, 99458, 99535, 99536, 100583,100586,101599,
		101933,101934,101935,101936,101937,101939,101940,101941,
	},
	{	-- "Mists of Pandaria"
		124124, 124125, 124126, 124127, 124128, 124129, 124549, 124551, 124552, 124553, 
		124554, 124559, 124561, 124563, 124564, 124565, 124566, 124567, 124568, 124569, 
		124571, 124572, 124573, 124574, 124575, 124576, 124577, 124578, 124579, 124580, 
		124581, 124582, 124583, 124584, 124585, 124586, 124587, 124588, 124589, 124590, 
		124591, 124592, 124593, 124594, 124595, 124596, 124597, 124598, 124599, 124600, 
		124601, 124602, 124603, 124604, 124605, 124606, 124607, 124608, 124609, 124610, 
		124611, 124612, 124613, 124614, 124615, 124616, 124617, 124618, 124619, 124620, 
		124621, 124622, 124623, 124624, 124625, 124626, 124627, 124628, 124635, 124636, 
		124637, 124638, 124639, 124640, 124641, 124642, 124643, 124644, 124645, 131865, 
	},
}

local smelting = {
	{	-- "Classic"
		2657, 2658, 2659, 3304, 3307, 3308, 3569, 10097, 10098, 14891,
		16153, 22967,
	},
	{	-- "The Burning Crusade"
		29356, 29358, 29359, 29360, 29361, 29686, 35750, 35751, 
	},
	{	-- "Wrath of the Lich King"
		46353, 49252, 49258, 55208, 55211, 70524, 
	},
	{	-- "Cataclysm"
		74529, 74530, 74537, 84038,
	},
	{	-- "Mists of Pandaria"
		102165, 102167
	},
}

local tailoring = {
	{	-- "Classic"
		2385, 2386, 2387, 2389, 2392, 2393, 2394, 2395, 2396, 2397, 
		2399, 2401, 2402, 2403, 2406, 2963, 2964, 3755, 3757, 3758, 
		3813, 3839, 3840, 3841, 3842, 3843, 3844, 3845, 3847, 3848, 
		3849, 3850, 3851, 3852, 3854, 3855, 3856, 3857, 3858, 3859, 
		3860, 3861, 3862, 3863, 3864, 3865, 3866, 3868, 3869, 3870, 
		3871, 3872, 3873, 3914, 3915, 6521, 6686, 6688, 6690, 6692, 
		6693, 6695, 7623, 7624, 7629, 7630, 7633, 7639, 7643, 7892, 
		7893, 8465, 8467, 8483, 8489, 8758, 8760, 8762, 8764, 8766, 
		8770, 8772, 8774, 8776, 8780, 8782, 8784, 8786, 8789, 8791, 
		8793, 8795, 8797, 8799, 8802, 8804, 12044, 12045, 12046, 12047, 
		12048, 12049, 12050, 12052, 12053, 12055, 12056, 12059, 12060, 12061, 
		12064, 12065, 12066, 12067, 12069, 12070, 12071, 12072, 12073, 12074, 
		12075, 12076, 12077, 12078, 12079, 12080, 12081, 12082, 12084, 12085, 
		12086, 12088, 12089, 12091, 12092, 12093, 18401, 18402, 18403, 18404, 
		18405, 18406, 18407, 18408, 18409, 18410, 18411, 18412, 18413, 18414, 
		18415, 18416, 18417, 18418, 18419, 18420, 18421, 18422, 18423, 18424, 
		18434, 18436, 18437, 18438, 18439, 18440, 18441, 18442, 18444, 18445, 
		18446, 18447, 18448, 18449, 18450, 18451, 18452, 18453, 18454, 18455, 
		18456, 18457, 18458, 18560, 19435, 20848, 20849, 21945, 22759, 22813, 
		22866, 22867, 22868, 22869, 22870, 22902, 23662, 23663, 23664, 23665, 
		23666, 23667, 24091, 24092, 24093, 24901, 24902, 24903, 26085, 26086, 
		26087, 26403, 26407, 27659, 27660, 27724, 27725, 28205, 28207, 28208, 
		28209, 28210, 28480, 28481, 28482, 
	},
	{	-- "The Burning Crusade"
		26745, 26746, 26747, 26749, 26750, 26751, 26752, 26753, 26754, 26755, 
		26756, 26757, 26758, 26759, 26760, 26761, 26762, 26763, 26764, 26765, 
		26770, 26771, 26772, 26773, 26774, 26775, 26776, 26777, 26778, 26779, 
		26780, 26781, 26782, 26783, 26784, 27658, 31373, 31430, 31431, 31432, 
		31433, 31434, 31435, 31437, 31438, 31440, 31441, 31442, 31443, 31444, 
		31448, 31449, 31450, 31451, 31452, 31453, 31454, 31455, 31456, 31459, 
		31460, 36315, 36316, 36317, 36318, 36686, 37873, 37882, 37883, 37884, 
		40020, 40021, 40023, 40024, 40060, 41205, 41206, 41207, 41208, 44950, 
		44958, 46128, 46129, 46130, 46131, 49677, 50194, 50644, 50647, 
	},
	{	-- "Wrath of the Lich King"
		55642, 55769, 55777, 55898, 55899, 55900, 55901, 55902, 55903, 55904, 
		55906, 55907, 55908, 55910, 55911, 55913, 55914, 55919, 55920, 55921, 
		55922, 55923, 55924, 55925, 55941, 55943, 55993, 55994, 55995, 55996, 
		55997, 55998, 55999, 56000, 56001, 56002, 56003, 56004, 56005, 56006, 
		56007, 56008, 56009, 56010, 56011, 56014, 56015, 56016, 56017, 56018, 
		56019, 56020, 56021, 56022, 56023, 56024, 56025, 56026, 56027, 56028, 
		56029, 56030, 56031, 56034, 56039, 59582, 59583, 59584, 59585, 59586, 
		59587, 59588, 59589, 60969, 60971, 60990, 60993, 60994, 63203, 63204, 
		63205, 63206, 63742, 63924, 64729, 64730, 67064, 67065, 67066, 67079, 
		67144, 67145, 67146, 67147, 70550, 70551, 70552, 70553, 75597, 
	},
	{	-- "Cataclysm"
		-- MoP : 102171 removed
		74964, 75141, 75142, 75144, 75145, 75146, 75154, 75155, 75172, 75175, 
		75178, 75247, 75248, 75249, 75250, 75251, 75252, 75253, 75254, 75255, 
		75256, 75257, 75258, 75259, 75260, 75261, 75262, 75263, 75264, 75265, 
		75266, 75267, 75268, 75269, 75270, 75288, 75290, 75291, 75292, 75293, 
		75294, 75295, 75296, 75297, 75298, 75299, 75300, 75301, 75302, 75303, 
		75304, 75305, 75306, 75307, 75308, 75309, 75310, 94743, 99448, 99449, 
		99459, 99460, 99537, 100585,101920,101921,101922,101923,
	},
	{	-- "Mists of Pandaria"
		125481, 125482, 125483, 125496, 125497, 125523, 125524, 125525, 125526, 125527, 
		125528, 125529, 125530, 125531, 125532, 125533, 125534, 125535, 125536, 125537, 
		125538, 125539, 125540, 125541, 125542, 125543, 125544, 125545, 125546, 125547, 
		125548, 125549, 125550, 125551, 125552, 125553, 125554, 125555, 125556, 125557, 
		125558, 125559, 125560, 125561, 130325, 
	},
}


-- ** Secondary Skills **
local cooking = {
	{	-- "Classic"
		2538, 2539, 2540, 2541, 2542, 2543, 2544, 2545, 2546, 2547, 
		2548, 2549, 2795, 3370, 3371, 3372, 3373, 3376, 3377, 3397, 
		3398, 3399, 3400, 4094, 6412, 6413, 6414, 6415, 6416, 6418, 
		6419, 6499, 6500, 6501, 7213, 7751, 7752, 7753, 7754, 7755, 
		7827, 7828, 8238, 8604, 8607, 9513, 13028, 15853, 15855, 15856, 
		15861, 15863, 15865, 15906, 15910, 15915, 15933, 15935, 18238, 18239, 
		18240, 18241, 18242, 18243, 18244, 18245, 18246, 18247, 20626, 20916, 
		21143, 21144, 21175, 22480, 22761, 24418, 24801, 25659, 25704, 25954, 
	},
	{	-- "The Burning Crusade"
		28267, 33276, 33277, 33278, 33279, 33284, 33286, 33287, 33288, 33289, 
		33290, 33291, 33292, 33293, 33294, 33295, 33296, 36210, 37836, 38867, 
		38868, 42296, 42302, 42305, 43707, 43758, 43761, 43765, 43772, 43779, 
	},
	{	-- "Wrath of the Lich King"
		6417, 45022, 45549, 45550, 45551, 45552, 45553, 45554, 45555, 45556, 
		45557, 45558, 45559, 45560, 45561, 45562, 45563, 45564, 45565, 45566, 
		45567, 45568, 45569, 45570, 45571, 45695, 46684, 46688, 53056, 57421, 
		57423, 57433, 57434, 57435, 57436, 57437, 57438, 57439, 57440, 57441, 
		57442, 57443, 58065, 58512, 58521, 58523, 58525, 58527, 58528, 62044, 
		62045, 62049, 62050, 62051, 62350, 64054, 64358, 65454, 66034, 66035, 
		66036, 66037, 66038, 
	},
	{	-- "Cataclysm"
		88003, 88004, 88005, 88006, 88011, 88012, 88013, 88014, 88015, 88016, 
		88017, 88018, 88019, 88020, 88021, 88022, 88024, 88025, 88028, 88030, 
		88031, 88033, 88034, 88035, 88036, 88037, 88039, 88042, 88044, 88045, 
		88046, 88047, 93741, 96133, 
	},
	{	-- "Mists of Pandaria"
		104237, 104297, 104298, 104299, 104301, 104302, 104304, 104305, 104307, 104308, 
		104310, 104311, 124029, 124032, 124052, 124053, 124054, 124223, 124224, 124225, 
		124226, 124227, 124228, 124229, 124230, 124231, 124232, 124233, 124234, 125067, 
		125078, 125080, 125117, 125120, 125121, 125122, 125123, 125594, 125595, 125596, 
		125597, 125598, 125599, 125600, 125601, 125602, 125603, 
	},
}

local firstaid = {
	{	-- "Classic"
		3275, 3276, 3277, 3278, 7928, 7929, 7934, 7935, 10840, 10841, 18629, 18630, 23787,
	},
	{	-- "The Burning Crusade"
		27032, 27033,
	},
	{	-- "Wrath of the Lich King"
		45545, 45546,
	},
	{	-- "Cataclysm"
		74556, 74557, 74558,	88893,
	},
	{	-- "Mists of Pandaria"
		102697, 102698, 102699, 
	},
}

-- ** END DATA TABLES **

local tradeskills = {
	{ id = 2259, LPTCategory = "TradeskillLevels.Alchemy", recipes = alchemy },
	{ id = 3100, LPTCategory = "TradeskillLevels.Blacksmithing", recipes = blacksmithing },
	{ id = 7411, LPTCategory = "TradeskillLevels.Enchanting", recipes = enchanting },
	{ id = 4036, LPTCategory = "TradeskillLevels.Engineering", recipes = engineering },
	{ id = 45357, LPTCategory = "TradeskillLevels.Inscription", recipes = inscription },
	{ id = 25229, LPTCategory = "TradeskillLevels.Jewelcrafting", recipes = jewelcrafting },
	{ id = 2108, LPTCategory = "TradeskillLevels.Leatherworking", recipes = leatherworking },
	{ id = 2656, LPTCategory = "TradeskillLevels.Smelting", recipes = smelting },
	{ id = 3908, LPTCategory = "TradeskillLevels.Tailoring", recipes = tailoring },
	{ id = 2550, LPTCategory = "TradeskillLevels.Cooking", recipes = cooking },
	{ id = 3273, LPTCategory = "TradeskillLevels.First Aid", recipes = firstaid },
}

local xPacks = {
	EXPANSION_NAME0,	-- "Classic"
	EXPANSION_NAME1,	-- "The Burning Crusade"
	EXPANSION_NAME2,	-- "Wrath of the Lich King"
	EXPANSION_NAME3,	-- "Cataclysm"
	EXPANSION_NAME4,	-- "Mists of Pandaria"
}

local currentXPack = 1					-- default to wow classic
local currentTradeSkill = 1			-- default to alchemy
local currentDDMText
local currentItemID
local currentList
local currentPTCategory = tradeskills[currentTradeSkill].LPTCategory					-- current category in LibPeriodicTable

local DDM_Add = addon.Helpers.DDM_Add
local DDM_AddCloseMenu = addon.Helpers.DDM_AddCloseMenu
local DDM_AddTitle = addon.Helpers.DDM_AddTitle

local function OnXPackChange(self)
	currentXPack = self.value
	currentDDMText = xPacks[currentXPack]
	addon.Tabs.Grids:SetViewDDMText(currentDDMText)
	addon.Tabs.Grids:Update()
end

local function OnTradeSkillChange(self)
	CloseDropDownMenus()
	currentTradeSkill = self.value
	currentPTCategory = tradeskills[currentTradeSkill].LPTCategory
	addon.Tabs.Grids:Update()
end

local function DropDown_Initialize(self, level)

	if not level then return end

	local info = UIDropDownMenu_CreateInfo()
	
	if level == 1 then
		-- Sub Menu : Primary Skills
		info.text = PRIMARY_SKILLS
		info.hasArrow = 1
		info.value = 1
		UIDropDownMenu_AddButton(info, level)

		-- Sub Menu : Secondary Skills
		info.text = SECONDARY_SKILLS
		info.hasArrow = 1
		info.value = 2
		UIDropDownMenu_AddButton(info, level)

		info.isTitle	= 1
		info.hasArrow = nil
		info.text = ""
		info.icon = nil
		info.checked = nil
		info.notCheckable = 1
		UIDropDownMenu_AddButton(info, level)
		
		info = UIDropDownMenu_CreateInfo()
		
		-- XPack Selection
		for i, xpack in pairs(xPacks) do
			info.text = xpack
			info.hasArrow = nil
			info.value = i
			info.func = OnXPackChange
			info.icon = nil
			info.checked = (i==currentXPack)
			UIDropDownMenu_AddButton(info, level)
		end
		
		DDM_AddCloseMenu()
	
	elseif level == 2 then
		local spell, icon, _
		local firstSecondarySkill = 10
	
		if UIDROPDOWNMENU_MENU_VALUE == 1 then				-- Primary professions
			for i = 1, (firstSecondarySkill - 1) do
				spell, _, icon = GetSpellInfo(tradeskills[i].id)
				
				info.text = spell
				info.hasArrow = nil
				info.value = i
				info.func = OnTradeSkillChange
				info.icon = icon
				info.checked = (i==currentTradeSkill)
				UIDropDownMenu_AddButton(info, level)				
			end
		
		elseif UIDROPDOWNMENU_MENU_VALUE == 2 then		-- Secondary professions
			for i = firstSecondarySkill, #tradeskills do
				spell, _, icon = GetSpellInfo(tradeskills[i].id)
				
				info.text = spell
				info.hasArrow = nil
				info.value = i
				info.func = OnTradeSkillChange
				info.icon = icon
				info.checked = (i==currentTradeSkill)
				UIDropDownMenu_AddButton(info, level)				
			end
		end
	end
end

local function SortByCraftLevel(a, b)
	local o1, y1, g1, gr1 = DataStore:GetCraftLevels(a)	-- get color level : orange, yellow, green, grey
	local o2, y2, g2, gr2 = DataStore:GetCraftLevels(b)
	
	-- try the most common cases = by orange, then by yellow, then by green
	if o1 and o2 and o1 ~= o2 then
		return o1 < o2
	elseif y1 and y2 and y1 ~= y2 then
		return y1 < y2
	elseif g1 and g2 and g1 ~= g2 then
		return g1 < g2
	end	
	
	-- if none has worked, we have a craft with no value for one or multiple colors, so basically skip the missing ones
	-- ex: if no orange value, sort on yellow .. to be able to do so, start from the grey, then green, then yellow
	gr1 = gr1 or 0
	gr2 = gr2 or 0
	
	if gr1 ~= gr2 then
		return gr1 < gr2
	end
	
	g1 = g1 or gr1
	g2 = g2 or gr2
	
	if g1 ~= g2 then
		return g1 < g2
	end
	
	y1 = y1 or g1
	y2 = y2 or g2
	
	if y1 ~= y2 then
		return y1 < y2
	end
	
	-- if nothing worked, sort on spell id
	return a < b
end

local callbacks = {
	OnUpdate = function() 
			currentList = tradeskills[currentTradeSkill].recipes[currentXPack]
			if not currentList.isSorted then
				table.sort(currentList, SortByCraftLevel)
				currentList.isSorted = true
			end
			
			local prof = GetSpellInfo(tradeskills[currentTradeSkill].id)
			addon.Tabs.Grids:SetStatus(format("%s / %s", GREEN..prof, WHITE .. xPacks[currentXPack]))
		end,
	GetSize = function() return #currentList end,
	RowSetup = function(self, entry, row, dataRowID)
			local spellID = currentList[dataRowID]
			local orange, yellow, green, grey
			local itemName = GetSpellInfo(spellID)
			local text
			
			-- if not itemName then
				-- DEFAULT_CHAT_FRAME:AddMessage("spell : " .. spellID)
			-- end
			
			currentItemID = DataStore:GetCraftInfo(spellID)
			if currentItemID then
				orange, yellow, green, grey = DataStore:GetItemTradeSkillLevel(currentItemID, currentPTCategory)
			else	-- if the craft does not generate an item (ex: northrend research), then search by spell id 
				orange, yellow, green, grey = DataStore:GetCraftLevels(spellID)
			end
			
			if orange then
				text = format("%s\n%s %s %s %s",
					WHITE..itemName, 
					-- WHITE..spellID, 
					RECIPE_ORANGE..orange, 
					YELLOW..yellow, 
					RECIPE_GREEN..green, 
					RECIPE_GREY..grey )
			end
			
			text = text or format("%s", WHITE..itemName)
			
			local rowName = entry .. row
			_G[rowName.."Name"]:SetText(text)
			_G[rowName.."Name"]:SetJustifyH("LEFT")
			_G[rowName.."Name"]:SetPoint("TOPLEFT", 15, 0)
		end,
	ColumnSetup = function(self, entry, row, column, dataRowID, character)
			local itemName = entry.. row .. "Item" .. column;
			local itemTexture = _G[itemName .. "_Background"]
			local itemButton = _G[itemName]
			local itemText = _G[itemName .. "Name"]
			
			itemText:SetFontObject("GameFontNormalSmall")
			itemText:SetJustifyH("CENTER")
			itemText:SetPoint("BOTTOMRIGHT", 5, 0)
			itemTexture:SetDesaturated(0)
			itemTexture:SetTexCoord(0, 1, 0, 1)
			
			itemTexture:SetTexture(GetItemIcon(currentItemID) or ICON_QUESTIONMARK)

			local text = ICON_NOTREADY
			local vc = 0.25	-- vertex color
			local profession = DataStore:GetProfession(character, GetSpellInfo(tradeskills[currentTradeSkill].id))			

			if profession.NumCrafts ~= 0 then
				-- do not enable this yet .. working fine, but better if more filtering allowed. ==> filtering on rarity
				
				-- local _, _, itemRarity, itemLevel = GetItemInfo(currentItemID)
				-- if itemRarity and itemRarity >= 2 then
					-- local r, g, b = GetItemQualityColor(itemRarity)
					-- itemButton.border:SetVertexColor(r, g, b, 0.5)
					-- itemButton.border:Show()
				-- end
				
				if DataStore:IsCraftKnown(profession, currentList[dataRowID]) then
					vc = 1.0
					text = ICON_READY
				else
					vc = 0.4
				end
			end

			itemTexture:SetVertexColor(vc, vc, vc)
			itemText:SetText(text)
			itemButton.id = currentItemID
		end,
	OnEnter = function(self) 
			self.link = nil
			addon:Item_OnEnter(self) 
		end,
	OnClick = function(self, button)
			self.link = nil
			addon:Item_OnClick(self, button)
		end,
	OnLeave = function(self)
			GameTooltip:Hide() 
		end,
		
	InitViewDDM = function(frame, title) 
			frame:Show()
			title:Show()

			currentDDMText = currentDDMText or xPacks[1]
			
			UIDropDownMenu_SetWidth(frame, 100) 
			UIDropDownMenu_SetButtonWidth(frame, 20)
			UIDropDownMenu_SetText(frame, currentDDMText)
			addon:DDM_Initialize(frame, DropDown_Initialize)
		end,
}

addon.Tabs.Grids:RegisterGrid(7, callbacks)
